// hyb_yl/wentijine/wentijine.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  onsubmit: function(e) {
    var that = this
    var value = e.detail.value;
    var z_tw_money = value.z_tw_money;
    var openid = wx.getStorageSync('openid');
    var id = that.data.id
    app.util.request({
      'url': 'entry/wxapp/Questiommm',
      data: {
        id: id,
        z_tw_money: z_tw_money
      },
      success: function(res) {
        wx.showToast({
          title: "设置成功~",
          icon: "none",
          duration: 2e3,
          success: function () {
            setTimeout(function () {
              wx.navigateBack({
                detail: '1'
              })
            }, 1000) 
          }
        });

      },
      fail: function(err) {
        console.log(err)
      },

    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var that = this
    var id = options.zid
    that.setData({
      id: id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
    this.getMymoneysite()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  //查询我的问题金额
  getMymoneysite: function() {
    var that = this
    var openid = wx.getStorageSync('openid')
    app.util.request({
      'url': 'entry/wxapp/Mymoneysite',
      data: {
        openid: openid
      },
      success: function(res) {
        that.setData({
          z_tw_money: res.data.data.z_tw_money
        })
      },
      fail: function(err) {
        console.log(err)
      },

    })
  }
})